/**
 * Project Name:HomeActivity
 * Date:2016-6-3上午11:32:00
 * Copyright (c) 2016, askzhao All Rights Reserved.
 *
 */
package com.kkd.kkdapp.adapter;

import java.util.ArrayList;

import com.kkd.kkdapp.R;
import com.kkd.kkdapp.view.RoundProgressBar;
import com.kkd.kkdapp.view.shapeimageview.PorterShapeImageView;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * ClassName: RegularSelectorAdapter <br/>
 * date: 2016-6-3 上午11:32:00 <br/>
 * 
 * @author askzhao
 * @version
 */
public class RegularSelectorAdapter extends BaseAdapter {

	private Context mContext;
	private  ArrayList<String> mData;
	private int curPosition = 0;

	public RegularSelectorAdapter(Context context, ArrayList<String> arrayList) {
		mContext = context;
		mData = arrayList;
	}

	@Override
	public int getCount() {
		return mData.size();
	}

	@Override
	public Object getItem(int position) {
		return mData.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder mViewHolder;
		if(convertView==null){
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.regular_selector_item, null);
			mViewHolder = new ViewHolder();
			mViewHolder.nameTv = (TextView) convertView.findViewById(R.id.name);
			convertView.setTag(mViewHolder);
		}else{
			mViewHolder = (ViewHolder) convertView.getTag();
		}
		mViewHolder.nameTv.setText(mData.get(position));
		if(curPosition==position){
			convertView.setBackgroundColor(0xffeeebf6);	
		}else{
			convertView.setBackgroundColor(0xffffffff);	
		}
//		convertView.setOnClickListener(new )
		
		return convertView;
	}
	private class ViewHolder {
		TextView nameTv;
	}
	/**
	 * setCurPosition:(这里用一句话描述这个方法的作用). <br/>
	 * @author askzhao
	 * @param position
	 */
	public void setCurPosition(int position) {
		curPosition = position;		
	}
}
